package com.usian.controller;

import com.usian.pojo.Dto;
import com.usian.pojo.Etc;
import com.usian.pojo.User;
import com.usian.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("u")
public class UserController {
    @Autowired
    private UserService userService;
    @RequestMapping("login1")
    public String login(User user, Model model){
        User user1=userService.findOne(user);
        if (user1==null){
            return "login";
        }
        List<Etc> dtos=userService.findAll();
        model.addAttribute("dto",dtos);
        if (user.getRid()==1){
            return "show1";
        }
        return "show2";
    }
    //zhu
    @RequestMapping("zhu")
    public String zhu(User user){
       userService.add(user);
        return "login";
    }
    //toaddUser
    @RequestMapping("toaddUser")
    public String toaddUser(){
        return "adduser";
    }

}
